# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from rest_framework import mixins, viewsets
from rest_framework.pagination import PageNumberPagination
from django.shortcuts import render
from django_filters.rest_framework import DjangoFilterBackend

from rest_framework_extensions.cache.mixins import CacheResponseMixin



# # 广告位信息分页的类
# class AdtypePagination(PageNumberPagination):
#     page_size = 50
#     page_size_query_param = 'page_size'
#     page_query_param = "page"
#     max_page_size = 100
#
#
class customerPagination(PageNumberPagination):
    page_size = 10
    page_size_query_param = 'page_size'	    
    page_query_param = "page"
    max_page_size = 100

import models 
#from .serializer import AdsInfoSerializer,AdsInfoListSerializer
import serializer
# # 广告商、代理商用户名的VIewSet
# class CustomerViewSet(CacheResponseMixin, mixins.ListModelMixin, mixins.RetrieveModelMixin,
#                       viewsets.GenericViewSet):
#     # queryset = UserPro.objects.exclude(level='admin')
#
#     pagination_class = customerPagination
#     filter_backends = (DjangoFilterBackend,)
#     filter_class = CustomerFilter

class AdinfoViewSet(viewsets.GenericViewSet, mixins.CreateModelMixin, mixins.DestroyModelMixin,mixins.ListModelMixin,mixins.RetrieveModelMixin,mixins.UpdateModelMixin):
    pagination_class = customerPagination

    def get_queryset(self):
        return AdsInfo.objects.all()
    def get_serializer_class(self):
	if self.action=='list':
	    return AdsInfoListSerializer
	else:
	    return AdsInfoSerializer


